# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=atk

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.12.0
pkgrel=1
pkgdesc="A library providing a set of interfaces for accessibility (mingw-w64)"
arch=('any')
url="http://www.gtk.org"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-glib2>=2.38.0")
options=('strip' 'staticlibs')
install=atk-${CARCH}.install
source=("http://ftp.gnome.org/pub/gnome/sources/atk/${pkgver%.*}/${_realname}-$pkgver.tar.xz"
    0001-create-libdir.mingw.patch
    0003-give-cc-to-git-scanner.mingw.patch
    0004-export-missing-symbol.all.patch
    0005-export-by-regex.all.patch)
md5sums=('930238dec55fdbf8eda9975b44f07b76'
         '9621eafe76e816b55113933ead6bbb07'
         '0c46709d1b08356dbb30560e8b9232b3'
         '31147a50932202178d844e614d30022d'
         '91d8de025137c620d2490e142c2c77f3')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-create-libdir.mingw.patch
  patch -p1 -i ${srcdir}/0003-give-cc-to-git-scanner.mingw.patch
  patch -p1 -i ${srcdir}/0004-export-missing-symbol.all.patch
  patch -p1 -i ${srcdir}/0005-export-by-regex.all.patch
  
  autoreconf -fi
}

build() {
  CFLAGS+=" -mms-bitfields"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --enable-introspection \
    --disable-glibtest
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
}
